package cn.sh.yhk.service.impl;

import cn.sh.yhk.mapper.MaitaiInfoMapper;
import cn.sh.yhk.model.po.MaitaiInfoPo;
import cn.sh.yhk.service.MaotaiInfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Yhk
 * @since 2024-09-07
 */
@Service
public class MaitaiInfoServiceImpl extends ServiceImpl<MaitaiInfoMapper, MaitaiInfoPo> implements MaotaiInfoService {
    @Autowired
    MaitaiInfoMapper maitaiInfoMapper;

    @Override
    public Page<MaitaiInfoPo> getMaotaiInfoPage(int page, int pageSize, MaitaiInfoPo po) {
        Page<MaitaiInfoPo> rowPage = new Page(page, pageSize);
        LambdaQueryWrapper<MaitaiInfoPo> queryWrapper = new LambdaQueryWrapper<>();
        if (!ObjectUtils.isEmpty(po.getQrcode())) {
            queryWrapper.eq(MaitaiInfoPo::getQrcode, po.getQrcode());
        }
        rowPage = maitaiInfoMapper.selectPage(rowPage, queryWrapper);
        for (MaitaiInfoPo record : rowPage.getRecords()) {
            record.setImages(record.getImages().substring(1, record.getImages().length() - 1));
        }
        return rowPage;

    }
}


